 

$(document).ready(function() {
  var timerIn, timerOut;
  var $growth = $('.growth')
  var $drops = $growth.find('.dropdown-menu');
  $growth.children('.item').on('mouseover', function() {
    var $drop = $(this).children('.dropdown-menu');
    $drops.hide();
    $drop.show();
    timerOut && clearTimeout(timerOut);
  }).on('mouseout', function() {
    var $drop = $(this).children('.dropdown-menu');
    timerOut = setTimeout(function() {
      $drop.hide();
    }, 250);
  });
});

$(document).ready(function() {
  // ie9, 样式用
  if (document.documentMode && document.documentMode === 9) {
    $('html').addClass('ie9');
  }

  // IE6-7 :focus
  // if (!'1'[0]) {
    var $box = $('.search-box2')
    $box.find('.input-text')
    .on('focus', function() {
      $box.addClass('focus');
      $(this).val('')
    })
    .on('blur', function() {
      $box.removeClass('focus');
    });
  // }

  $('.checkbox').on('click', 'a', function(e) {
    var $input = $(this).siblings('input');
    var $parent = $(this).parent();
    if ($input.prop('checked')) {
      $parent.removeClass('checked');
      $input.prop('checked', false);
    } else {
      $parent.addClass('checked');
      $input.prop('checked', true);
    }
    e.preventDefault();
  });

});

$(document).ready(function() {
  // 搜索框
  var $box = $('.search-box');
  var $form = $box.children('form');
  var $label = $form.children('label');
  var $input = $form.children('.input-text');
  var showHide = function() {
    if (!$.trim($input.val())) {
      $label.show();
      $input.val('');
    } else {
      $label.hide();
    }
  };

  showHide();

  $label.on('click', function() {
    $input.focus();
  });

  $input.on('focus', function() {
    $label.hide();
  }).on('blur', function() {
    showHide();
  });

  $form.on('submit', function() {
    if (!$.trim($input.val())) {
      $input.focus();
      return false;
    }
  });

});
$(document).ready(function() {
  var $specialIssues = $('.special-issues').on('click', function(e) {
    if (!$(e.target).is('a')) {
      location.href = $specialIssues.find('.enter').attr('href');
    }
  }).hover(function() {
    $specialIssues.css('cursor', 'pointer');
  }, function() {
    $specialIssues.css('cursor', 'default');
  });
});
/**
 * 返回顶部
 *
 * 暂不考虑 IE6
 *
 */

$(document).ready(function() {
  'use strict';

  var $totop = $('#tobox').children('.totop');
  var isIE6 = !-[1, ] && !window.XMLHttpRequest;

  $(window).on('scroll', function() {
    var t = document.documentElement.scrollTop || document.body.scrollTop;
    $totop.toggleClass('show', t > 80);
  });

  if (!isIE6) {
    $totop.on('click', function(e) {
      $("html, body").animate({scrollTop: 0}, 500);
      e.preventDefault();
    });
  } else {
    $totop.on('click', function(e) {
      windown.scrollTo(0, 0);
      e.preventDefault();
    });
  }

});
//新补充与新加的JS 

$(function(){
	var parten =/^\s*$/;
	var get_inpt=$(".quer_serch .quer_a_input");
	var get_val=get_inpt.prop("value");
	var get_inpt2=$(".quer_nag_li_4 .quer_li_input");
	var get_val2=get_inpt2.prop("value");
	get_inpt.focus(function(){
		if(get_inpt.val()==get_val){
			get_inpt.val("");
			}
		})
	get_inpt.focusout(function(){
		if(parten.test(get_inpt.val().replace(/[\u3000]/g,""))){
			get_inpt.val(get_val);
			}
		})
	get_inpt2.focus(function(){
		if(get_inpt2.val()==get_val2){
			get_inpt2.val("");
			}
		})
	get_inpt2.focusout(function(){
		if(parten.test(get_inpt2.val().replace(/[\u3000]/g,""))){
			get_inpt2.val(get_val2);
			}
		})
	
	//上部列表打开与收起。
	var get_top_div=$("#quer_top_clic").parent(".quer_main_top");
	var div_high=get_top_div.height();
	$("#quer_top_clic").click(function(){
		if($(this).hasClass("topli_botm_add")){
			$(this).removeClass("topli_botm_add");
			get_top_div.animate({"height":div_high},{duration: 500, easing:"easeInOutQuart"})
			}else{
				$(this).addClass("topli_botm_add");
				get_top_div.animate({"height":0},{duration: 500, easing:"easeInOutQuart"})
				}
		})
	//每个用户的详细显示与隐藏
	$(".user_img_ifo").hover(function(){
		$(this).children(".user_bomb").fadeIn(100);
		},function(){$(this).children(".user_bomb").fadeOut(100);})
		
	var get_data_show=$("#quer_list_show>li");	
	$("#qu_data_nag>li").click(function(){
		$(this).addClass("qu_data_list").siblings().removeClass("qu_data_list");
		get_data_show.eq($(this).index()).addClass("quer_data_show").siblings().removeClass("quer_data_show");
		})
	
	$("textarea").focus(function(){
			$(this).text(" ")
		})
	$(".qu_main_toplist li").hover(function(){
		$(this).addClass("p_fontco");
		},function(){
			$(this).removeClass("p_fontco");})
	//二维码定位
	var get_pos=$(".two_code");
	pos_code();
	$(window).resize(function(){
		 pos_code();
		});
	function pos_code(){
		var wid_w=document.documentElement.clientWidth;
		var wid_h=document.documentElement.clientHeight;
		get_pos.css({"left":(wid_w-1000)/2-117})
		if(wid_w>1220){
		get_pos.show(300);
		}else{
			get_pos.hide();
			}
		}
	$("#tocomment").click(function(){
		$.scrollTo($("#divcommentboxhd").parents(".comment-post"),800);
		})
	
	
	//发现页到顶部
	var top_body;
	$(window).scroll(function(){
		top_body=$(this).scrollTop();
		if(top_body>100){
			top_body=$(this).scrollTop();
			$("#to_top").show()
			}else{
				$("#to_top").hide()}
		});
	$('#to_top').click(function(){
		var kk=$("html")
		if(top_body<300){
			top_body=top_body;
			}else{
				top_body=600;
				}
	$.scrollTo(kk,{duration:top_body, easing:"easeInOutCirc"});});
	
//	/*模拟加载*/
//	$(".click_more").click(function(){
// 
//		if($(this).hasClass("click_more_add")){
//			
//			$(this).removeClass("click_more_add").text("点击~展开更多！");
//			}else{
//				$(this).addClass("click_more_add").text("");
//				
//				val=$('#page_num')[0].value;
//				$.get('{:U("/comments/Comments/loadMoreComments")}'+"&page="+val, function(data){
//					  $('.comment-list').append(data);				    	                                                  
//				  });
//				
//               	$('#page_num').val(1+parseInt(val));
//				
//				}
//		})
//	/*回复点击*/
//	$(".pre_re").click(function(){
//		var get_li=$(this).parents(".comment-item");
//		var get_bom=$(".user_subm",get_li);
//		if(get_bom.is(":hidden")){
//			get_bom.slideDown(300);
//			}else{
//				get_bom.slideUp(300);
//				}
//		})
	$(".comment-list").on('click','.pre_re', function() {
			var get_li=$(this).parents(".comment-item");
			var get_bom=$(".user_subm",get_li);
			if(get_bom.is(":hidden")){
				get_bom.slideDown(300);
				}else{
					get_bom.slideUp(300);
					}
		});
		
		
	
	
	})


/**********************************************滑动到顶部 通过IE7及以上*********/
;(function( $ ){
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};
	$scrollTo.defaults = {
		axis:'y',
		duration:1
	};
	$scrollTo.window = function( scope ){
		return $(window).scrollable();
	};
	$.fn.scrollable = function(){
		return this.map(function(){
			var win = this.parentWindow || this.defaultView,
				elem = this.nodeName == '#document' ? win.frameElement || win : this,
				doc = elem.contentDocument || (elem.contentWindow || elem).document,
				isWin = elem.setInterval,
				tex_= new RegExp("Safari");
			return elem.nodeName == 'IFRAME' || isWin && tex_.test(window.navigator.appVersion) ? doc.body
				: isWin ? doc.documentElement
				: this;
		});
	};
	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };	
		settings = $.extend( {}, $scrollTo.defaults, settings );
		duration = duration || settings.speed || settings.duration;
		settings.queue = settings.queue && settings.axis.length > 1;
		if( settings.queue )
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );
		return this.scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');
			switch( typeof targ ){
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(px)?$/.test(targ) ){
						targ = both( targ );
						break;
					}
					targ = $(targ,this);
				case 'object':
					if( targ.is || targ.style )
	
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					Dim = axis == 'x' ? 'Width' : 'Height',
					dim = Dim.toLowerCase();
				if( toff ){
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}
					attr[key] += settings.offset[pos] || 0;
					if( settings.over[pos] )
						attr[key] += targ[dim]() * settings.over[pos];
				}else
					attr[key] = targ[pos];
				if( /^\d+$/.test(attr[key]) )
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) );
				if( !i && settings.queue ){
					if( old != attr[key] )
						animate( settings.onAfterFirst );
					delete attr[key];
				}
			});			
			animate( settings.onAfter );			
			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback && function(){
					callback.call(this, target, settings);
				});
			};
			function max( Dim ){
				var attr ='scroll'+Dim,
					doc = elem.ownerDocument;
				
				return win
						? Math.max( doc.documentElement[attr], doc.body[attr]  )
						: elem[attr];
			};
		}).end();
	};
	function both( val ){
		return typeof val == 'object' ? val : { top:val, left:val };
	};
})( jQuery );
/**********************************************end*****************************************************/